<%@page import="com.hamizhong.iflowers.utils.MyColumnIndicator"%>
<%@page import="com.hamizhong.iflowers.web.vo.OrdersVO"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%@include file="../common/common.jsp" %>
<title>订单详情</title>
</head>
<%
OrdersVO ordersVO = (OrdersVO)request.getAttribute("ordersVO");
%>
<body>
	<%@include file="frame/top.jsp" %>
	<div class="main_div">
		<%@include file="frame/navigation.jsp" %>
		<div style="width: 990px;height: auto;margin: 0 auto;overflow: hidden;">
			<div style="width: 990px;height: auto;margin: 0 auto;overflow: hidden;">
				<div style="width: 100%;height: 30px;line-height: 30px;background: none repeat scroll 0 0 #EFEFEF;border: 1px solid #CCCCCC;">
					<font style="font-weight: bold;margin-left: 5px;">订单详情-<%=ordersVO.getGoodsVO().getGoodsName() %></font>
				</div>
				<div id="orderDetailDiv" style="width: 988px;height: auto;overflow: hidden;border: 1px solid #CCC;border-top: 0;">
					<table border="1px" width="100%">
						<tr>
							<td>商品图片</td>
							<td><div style="width: 60px;height: 60px;"><img width="56px" height="56px"  style="margin: 2px;" alt="" src="<%=request.getContextPath() %>/<%=ordersVO.getGoodsVO().getGoodsPictureS() %>" /></div></td>
						</tr>
						<tr>
							<td>订单编号</td>
							<td><%=ordersVO.getOrderNum() %></td>
						</tr>
						<tr>
							<td>商品名称</td>
							<td><%=ordersVO.getGoodsVO().getGoodsName() %></td>
						</tr>
						<tr>
							<td>购买数量</td>
							<td><%=ordersVO.getGoodsCnt() %></td>
						</tr>
						<tr>
							<td>订单总价</td>
							<td><%=ordersVO.getOrderPrice() %></td>
						</tr>
						<tr>
							<td>订单状态</td>
							<td><%=ordersVO.getOrderStateStr() %></td>
						</tr>
						<%
							if(ordersVO.getOrderState() == MyColumnIndicator.O_ST_D) {
						%>
						<tr>
							<td>订单评价</td>
							<td><%=ordersVO.getOrdersComment() %></td>
						</tr>
						<%
							}
						%>
						<tr>
							<td>最新时间</td>
							<td><%=ordersVO.getDoneDateStr() %></td>
						</tr>
						<tr>
							<td>创建时间</td>
							<td><%=ordersVO.getCreateDateStr() %></td>
						</tr>
						<tr>
							<td>收货城市</td>
							<td><%=ordersVO.getCityVO().getCityName() %></td>
						</tr>
						<tr>
							<td>收货人姓名</td>
							<td><%=ordersVO.getConsigneeName() %></td>
						</tr>
						<tr>
							<td>收货人电话</td>
							<td><%=ordersVO.getConsigneePhone() %></td>
						</tr>
						<tr>
							<td>收货地邮编</td>
							<td><%=ordersVO.getZip() %></td>
						</tr>
						<tr>
							<td>收货人地址</td>
							<td><%=ordersVO.getConsigneeAddr() %></td>
						</tr>
						<tr>
							<td>订单备注</td>
							<td><%=ordersVO.getRemarks() %></td>
						</tr>
					</table>
				</div>
			</div>
			<div style="clear: both;width: 100%;height: 5px;"></div>
			<div style="width: 990px;height: auto;margin: 0 auto;overflow: hidden;">
				<div style="width: 100%;height: 30px;line-height: 30px;background: none repeat scroll 0 0 #EFEFEF;border: 1px solid #CCCCCC;">
					<font style="font-weight: bold;margin-left: 5px;">订单操作</font>
				</div>
				<div id="orderOperationDiv" style="width: 988px;height: 100px;border: 1px solid #CCC;border-top: 0;padding-top: 30px;">
					<%
						if(ordersVO.getOrderState() == MyColumnIndicator.O_ST_A) {			//订单状态-刚生成订单（待发货）
					%>
						<input type="button" onclick="updateOrderState('<%=ordersVO.getOrderId() %>','<%=MyColumnIndicator.O_ST_BACK_A %>')" value="订单退订">
					<%
						}else if(ordersVO.getOrderState() == MyColumnIndicator.O_ST_B) {	//订单状态-已发货（待签收）
					%>
						<input type="button" onclick="updateOrderState('<%=ordersVO.getOrderId() %>','<%=MyColumnIndicator.O_ST_C %>')" value="确认签收">
					<%	
						}else if(ordersVO.getOrderState() == MyColumnIndicator.O_ST_C) {	//订单状态-已签收（待评论）
					%>
						订单评价：<textarea id="orderComment" name="orderComment" rows="" cols="" style="width: 200px;height: 40px;"></textarea>
						<input type="button" onclick="updateOrderState('<%=ordersVO.getOrderId() %>','<%=MyColumnIndicator.O_ST_D %>')" value="评价订单">
					<%
						}else if(ordersVO.getOrderState() == MyColumnIndicator.O_ST_E) {
					%>
						<input type="button" onclick="updateOrderState('<%=ordersVO.getOrderId() %>','<%=MyColumnIndicator.O_ST_A %>')" value="模拟付款">
					<%
						}else {
					%>
						<font color="green">当前订单状态暂无操作项！</font>
					<%
						}
					%>
				</div>
			</div>
		</div>
	</div>
	<%@include file="frame/feet.jsp" %>
</body>

<script type="text/javascript">

	function updateOrderState(orderId, newState) {
		//alert(orderId+"|"+origState+"|"+newState);
		var orderComment = $('#orderComment').val();
		if(newState == <%=MyColumnIndicator.O_ST_D %>) {
			if(orderComment == null || orderComment == '') {
				alert("请先填入评价信息后再提交！");
				$('#orderComment').focus();
				return false;
			}
		}
		$.ajax({
			url: '<%=request.getContextPath() %>/ajaxUpdateOrderStateC.action',
			data: {
				"orderId": orderId,
				"newState": newState,
				"orderComment": orderComment
			},
			type: 'post',
			async: false,
			dataType: 'json',
			success: function(res) {
				var rs = res.result;
				if(rs != 0) {
					alert(res.msg);
				}else {
					alert("操作成功！");
				}
				location.reload();
			}
		});
	}
	
</script>

</html>